<?php

namespace app\Api\controller;

use app\common\business\SPlatform;
use app\common\lib\Check;

class Banner extends ApiBase
{
    //首页轮播图
    public function bannerList(){
        $banner_show = $this->request->param("banner_show","","trim");
        if(empty($banner_show)){
            return show(config("status.error"),"展示类型不能为空");
        }
        $where[] = ["banner_show", "=", $banner_show];
        $where[] = ["status", "=", '0'];
        $where[] = ["del_flag", "=", '0'];
        try {
            $field = "banner_id,banner_img,banner_type,banner_url";
            $bannerData = (new SPlatform())->getNormalBannerNotPage($where, $field);
            // 处理图片URL
            foreach ($bannerData as &$banner) {
                $banner['banner_img'] = (new Check())->checkUrl($banner['banner_img']);
            }
        }catch (\Exception $e){
            $bannerData = [];
        }
        return show(config("status.success"),"轮播图列表",$bannerData);
    }
}
